<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="UTF-8">
<title>购物车</title>
<link rel="stylesheet" href="layui/css/layui.css" />
<script type="text/javascript" src="layui/layui.js"></script>
</head>
<body>
	<jsp:include page="/header"></jsp:include>
	 <!--=====================
Breadcrumb Aera Start
=========================-->
    <div class="breadcrumbs_area">
        <div class="container">
            <div class="row">
                <div class="col-12">
                    <div class="breadcrumb_content">
                        <ul>
                            <li>
                                <h1><a href="indexTwo">首页</a></h1>
                            </li>
                            <li>提交订单</li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--=====================
    Breadcrumb Aera End
    =========================-->
		
    <!--======================
    Checkout area Start
    ==========================-->
    <div class="checkout-area mt-50">
        <div class="container">
            <div class="row">
                <div class="col-lg-6 col-md-6">
                    <form  class="form-row layui-form" onsubmit="false">
                        <div class="col-lg-12">
                            <h5 class="form-head">结算明细</h5>
                        </div>
							<div class="form_group col-12">
                                        <label class="form-label" for="country">订单地址 <span><a class="btn btn-secondary" href="#"  id="add">添加</a></span></label>
                                        <select class="select-option" id="Standby_application_two" name="Standby_application_two">
                                        <c:forEach items="${addressid }" var="l">
                                            <option value="${l.addid }">${l.addprovince }，${l.addcity }，${l.adddistinct }，${l.Uharvest_people }（收），联系电话：${l.Uconsignee }</option>
                                        </c:forEach>
                                        </select>
                                    </div>
                    </form>
                    <div class="form-row mt-20 mb-15">
                        <div class="form_group mb-0 col-12">
                            <label class="form-label" for="order-note">订单备注</label>
                            <textarea class="form-textarea" id="order-note" placeholder=""></textarea>
                        </div>
                    </div>
                </div>
                <div class="col-lg-6 col-md-6">
                    <form class="form-row layui-form" onsubmit="false">
                        <div class="col-lg-12">
                            <h5 class="form-head rs-padding">您的订单</h5>
                        </div>
                        <div class="col-lg-12">
                            <div class="order_table table-responsive">
                                <table>
                                    <thead>
                                        <tr>
                                            <th>产品x数量</th>
                                            <th>总价</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    <c:forEach items="${shoppcar }" var="s">
                                    	 <tr class="pro_list">
                                            <td> ${s.Pname } <strong> × ${s.Shshopp_sum }</strong></td>
                                            <td> ${s.Standby_application_one }</td>
                                            <td hidden="hidden">
                                            	<h6>
	                                            <input required=""  autocomplete="off" class="layui-input" type="text" lay-verify="required" value="${s.Standby_application_one }" name="Dtotal_price" id="Dtotal_price" >
                                            	</h6>
	                                            <span>
	                                            	 <input required=""  autocomplete="off" class="layui-input pid" type="text" lay-verify="required" value="${s.Pid }" name="Pid" id="Pid" >
	                                            </span>
	                                            <div>
	                                             <input required=""  autocomplete="off" class="layui-input" type="text" lay-verify="required" value="${s.Sid }" name="Sid" id="Sid" >
	                                            </div>
	                                            <p>
	                                            <input required=""  autocomplete="off" class="layui-input" type="text" lay-verify="required" value="${s.Shshopp_sum }" name="Dsum" id="Dsum"  >
	                                            </p>
	                                            <a>
	                                            <input required=""  autocomplete="off" class="layui-input" type="text" lay-verify="required" value="${s.Pprice }" name="Dprice" id="Dprice"  >
	                                            </a>
                                            </td>
                                        </tr>
                                    </c:forEach>
                                    </tbody>
                                    <tfoot>
                                        <tr class="order_total">
                                            <th>合计订单总价</th>
                                            <td><strong >${zonger[0].zonger }</strong>
                                            <input hidden="hidden" required=""  autocomplete="off" class="layui-input" type="text" lay-verify="required" value="${zonger[0].zonger }" name="zong" id="zong"  ></td>
                                        </tr>
                                    </tfoot>
                                </table>
                            </div>
                        </div>
                    </form>
                    
                    <div class="form-row layui-form justify-content-end mt-20 mb-20" onsubmit="false">
                        <input type="submit" class="btn-secondary"  lay-submit lay-filter="formDemo" value="继续付款">
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--======================
    Checkout area End
    ==========================-->

<!--===================
     footer area start 
    ===================-->
	<footer class="mt-30">
		<!-- Newslatter area start -->
		<div class="newsletter-group">
			<div class="container">
				<div class="row align-items-center">
					<div class="col-lg-6 col-12">
						<div class="newsletter-inner d-flex align-items-center">
							<i class="fa fa-envelope-open-o"></i>
							<div class="newsletter-title">
								<h1 class="sign-title">注册我们的通讯</h1>
								<p>获取有关我们最新商店和特惠信息的电子邮件更新。</p>
							</div>
						</div>
					</div>
					<div class="col-lg-6 col-12">
						<div class="newsletter-box">
							<form id="mc-form" class="mc-form">
								<input type="email" id="mc-email" class="email-box"
									placeholder="输入你的电子邮箱" name="EMAIL">
								<button id="mc-submit" class="newsletter-btn" type="submit">订阅</button>
							</form>
							<!-- mailchimp-alerts Start -->
							<div class="mailchimp-alerts text-centre">
								<div class="mailchimp-submitting"></div>
								<!-- mailchimp-submitting end -->
								<div class="mailchimp-success text-success"></div>
								<!-- mailchimp-success end -->
								<div class="mailchimp-error text-danger"></div>
								<!-- mailchimp-error end -->
							</div>
							<!-- mailchimp-alerts end -->
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- Newslatter area End -->
		<!-- Footer Top Start -->
		<div class="footer-top mt-50 mb-40">
			<div class="container">
				<div class="row">
					<div class="col-lg-4">
						<div class="footer-single-widget">
							<div class="footer-logo mb-40">
								<a href="index"><img
									src="assets/images/logo/pos-circle-logo.jpg" alt=""></a>
							</div>
							<div class="widget-body">
								<div class="widget-address mt-30 mb-20">
									<p>
										<strong>地址:</strong>新乡市，红旗区，新乡职业技术学院
									</p>
									<p>
										<strong>联系电话:</strong> (800) 123 456 - (800) 123 456.
									</p>
									<p>
										<strong>电子邮箱:</strong> support@circleshop.com
									</p>
								</div>
							</div>
						</div>
					</div>
					<div class="col-lg-8">
						<div class="row">
							<div class="col-lg-3 col-md-3 col-6">
								<div class="widgets_container">
									<h6>信息</h6>
									<div class="footer_menu">
										<ul>
											<li><a href="#">隐私政策</a></li>
											<li><a href="#">条款及细则</a></li>
										</ul>
									</div>
								</div>
							</div>
							<div class="col-lg-3 col-md-3 col-6">
								<div class="widgets_container">
									<h6>我的账户</h6>
									<div class="footer_menu">
										<ul>
											<li><a href="#">我的帐户</a></li>
											<li><a href="#">心愿单</a></li>
										</ul>
									</div>
								</div>
							</div>
							<div class="col-lg-3 col-md-3 col-6">
								<div class="widgets_container">
									<h6>快速找到</h6>
									<div class="footer_menu">
										<ul>
											<li><a href="#">历史悠久</a></li>
											<li><a href="#">新闻快报</a></li>
										</ul>
									</div>
								</div>
							</div>
							<div class="col-lg-3 col-md-3 col-6">
								<div class="widgets_container">
									<h6>客户服务</h6>
									<div class="footer_menu">
										<ul>
											<li><a href="#">网站地图</a></li>
											<li><a href="#">联系我们</a></li>
										</ul>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- Footer Top End -->
	</footer>
	<!--===================
     footer area end 
    ===================-->


	<!-- Use the minified version files listed below for better performance and remove the files listed above -->
	<script src="assets/js/vendor/vendor.min.js"></script>
	<script src="assets/js/plugins/plugins.min.js"></script>

	<!-- Main JS -->
	<script src="assets/js/main.js"></script>
	<script>
		//Demo
		layui.use('form', function() {
			var form = layui.form;
			var $ = layui.jquery;
			//监听提交
			form.on('submit(formDemo)', function(data) {
				var url = '/shoppingsix/orders_add';
				console.log(1111111111);
				var pids=[];
				var trs=$(".pro_list");
				for (var i = 0; i < trs.length; i++) {
					 var tds=$(trs[i]).find("td")[2]; 
					 var spans= $(tds).find("span");
					 var spans1= $(tds).find("div");
					 var spans2= $(tds).find("p");
					 var spans3= $(tds).find("a");
					 var spans4= $(tds).find("h6");
					 var p_id=$(spans).find('input').val();
					 var s_id=$(spans1).find('input').val();
					 var num=$(spans2).find('input').val();
					 var price=$(spans3).find('input').val();
					 var Dtotal_price=$(spans4).find('input').val();
					 var pro={'pid':p_id,'sid':s_id,'num':num,'price':price,'Dtotal_price':Dtotal_price};
					  pids.push(pro);
				}
			 	$.post(url, {
					 'zong':$("#zong").val(),
					 'Standby_application_two':$("#Standby_application_two").val(),
					 'pids':JSON.stringify(pids),
					 //'Sid':$("#Sid").val(),
					 //'Dsum':$("#Dsum").val(),
					// 'Dprice':$("#Dprice").val(),
					// 'Dtotal_price':$("#Dtotal_price").val()
				}, function(data) {
					if (data.count > 0) {
						console.log('添加成功');
						console.log(data.data);
						console.log(data.data[0].Oid);
						 window.location.href = "indexPay?Oid="+data.data[0].Oid; 
						/*  window.location.href = "my-account";  */
					}
				}, "json"); 
				return false;
			});
			/* 添加按钮 */
			$('#add').on('click', function() {
				layer.open({//打开一个页面
					type : 2,//在当前页面打开一个页面
					area : [ '550px', '600px' ],//页面宽高
					content : 'address-add.jsp',//页面地址
					title : '新增订单地址',//打开页面标题
					end : function() {
						window.location.reload();//当窗口关闭后刷新页面
					}
				});
			});
		});
	</script>
	
</body>
</html>